﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimKen.DataEntity;
using TimKen.BussLogic;
using System.Data;
using TimKen.App;


namespace TimKen.Web.Admin.CompanyCulture
{
    public partial class CompanyCulture_Edit : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(this.ddlLanguage);
            if (!Page.IsPostBack)
            {
                BindResources();
                BindData();
            }
        }   

        protected void BindResources()
        {
            ddlLanguage.Items.Clear();
            ListItem li_ZH = new ListItem("简体中文", "1");
            ListItem li_EN = new ListItem("English", "2");
            ddlLanguage.Items.Add(li_ZH);
            ddlLanguage.Items.Add(li_EN);

            btnConfirm.Text = GetLangString("Save");
        }

        private void BindData()
        {
            string LanguageID = this.ddlLanguage.SelectedValue;

            ArticleManager am = new ArticleManager();
            List<DataEntity.Article>  articleList = am.GetModelList("  TypeID=5 AND LanguageID="+LanguageID);
              DataEntity.Article culture;
            culture =  articleList[0];

            this.fckContent.Value = culture.Content;
           
        }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            string LanguageID = this.ddlLanguage.SelectedValue;
            ArticleManager am = new ArticleManager();
            List<DataEntity.Article> articleList = am.GetModelList("  TypeID=5 AND LanguageID=" + LanguageID);
            DataEntity.Article culture;
            culture = articleList[0];

            culture.Content =  this.fckContent.Value;

            am.Update(culture);

        }

        protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
